package com.hayabusa.mapper;/*
 * @author Hayabusa
 * @date  2021/3/31 14:21
 * @Email:2682557218@qq.com
 */


import com.hayabusa.pojo.User;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public interface UserMapper {
    /**
     * 查询所有用户
     * @return
     */

    @Select("select * from user")
    List<User> findAll();

    /**
     * 模糊查询用户
     * like concat('%',#{username},'%')
     * @param searchName
     * @return
     */
    @Select("select * from user where username = #{searchName} ")
    User findByUserName(String searchName);

    @Delete("delete from user where id=#{value}")
    int delById(Integer id);

    @Select("select * from user where id=#{value}")
    User findById(Integer id);

    @Update("update user set username = #{username},password =#{password} where id = #{id}")
    void editById(@Param("id") Integer id, @Param("username") String username, @Param("password") String password);

    @Select("select * from user where email=#{value}")
    User getByEmail(String email);

    @Insert("insert into user (id,username,email,password,power) values (#{id},#{userName},#{email},#{passWord},#{role})")
    int insertUser(User user);


}
